<template>
  <div class="main">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="学习日记（132）" name="first">
        <div class="top_title">
          <p>
            在Timing中，用户会用"学习日记"来记录学习历程，分享学习经验，"学习日记"有文字+图片和文字+视频两种形式，一篇好的"学习日记",能够获得大量的曝光，吸引更多人的关注。
            <a href="#">了解更多>></a>
          </p>
        </div>
        <div class="contain_list">
          <li v-for="(item, index) in list" :key="index">
            <div class="list_top">
              <div class="top_left">
                <img :src="item.userimg" alt="" />
                <div class="info">
                  <p>{{ item.username }}</p>
                  <p>{{ item.time }}</p>
                </div>
              </div>
              <div class="right" style="margin-right: 20px">
                <i class="el-icon-delete"></i>
              </div>
            </div>
            <div class="list_content">
              <div class="top">
                {{ item.content }}
              </div>
              <div
                class="list_img"
                v-for="(item, index) in imglist"
                :key="index"
              >
                <img :src="item.img" alt="" />
              </div>
              <div>
                <i class="iconfont icon-dianzan"></i>{{ item.dianzan }}
                <i class="iconfont icon-icon_comment"></i>{{ item.pinglun }}
                <i class="iconfont icon-zhuanfa"></i>{{ item.zhuanfa }}
              </div>
              <hr />
            </div>
          </li>
        </div>
        <el-pagination
          @current-change="currentPage"
          @next-click="nextPage"
          @prev-click="prevPage"
          background
          layout="prev, pager, next"
          :total="50"
          :page-size:="pagesize"
        >
        </el-pagination>
      </el-tab-pane>

      <el-tab-pane label="长视频(675)" name="second">长视频(675)</el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import axios from "axios";
export default {
  name: "Home",
  components: {},
  data() {
    return {
      activeName: "first",
      list: [],
      pageindex: 1,
      pagesize: 3,
      imglist: [
        {
          img: "https://img2.baidu.com/it/u=1205915504,3217808836&fm=26&fmt=auto&gp=0.jpg",
          img: "https://img2.baidu.com/it/u=1077360284,2857506492&fm=26&fmt=auto&gp=0.jpg",
          img: "https://img1.baidu.com/it/u=2838780513,3053016818&fm=26&fmt=auto&gp=0.jpg",
        },
      ],
    };
  },
  created() {
    this.getlist();
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    getlist() {
      axios
        .get("/api/get/list", {
          params: {
            userimg: this.userimg,
            username: this.username,
            time: this.time,
            content: this.content,
            contentimg: this.contentimg,
            dianzan: this.dianzan,
            pinglun: this.pinglun,
            zhuanfa: this.zhuanfa,
            pageindex: this.pageindex,
            pagesize: this.pagesize,
          },
        })
        .then((res) => {
          console.log(res);
          this.list = res.data.list;
        });
    },
    nextPage() {
      this.pageindex++;
      this.getlist();
    },
    prevPage() {
      this.pageindex--;
      this.getlist();
    },
    currentPage(pageindex) {
      this.pageindex = pageindex;
      this.getlist();
    },
  },
};
</script>

<style>
.el-pagination {
  float: right;
  margin-right: 30px;
}
li {
  list-style-type: none;
}

.list_img {
  margin-top: 10px;
  margin-bottom: 10px;
}
.list_img img {
  width: 100px;
  height: 100px;
  margin-right: 20px;
}
.list_content {
  width: 90%;
  margin: 0 50px;
}
.top_left {
  display: flex;
  align-items: center;
}
.list_top {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.list_top img {
  width: 30px;
  height: 30px;
  margin: 0 10px;
  border-radius: 20px;
}
.info {
  line-height: 5px;
}
.el-tab-pane:nth-child(1) {
  font-size: 12px;
  font-weight: 400;
  font-family: PingFangSC-Regular, PingFang SC;
  color: rgba(57, 57, 57, 0.6);
}
.el-tab-pane:nth-child(1) a {
  text-decoration: none;
  color: #00c896;
}
.top_title {
  padding-left: 20px;
}
/* .el-tab-pane {
  height: 1000px;
} */
.main {
  width: 100%;
  background-color: #fff;
}

.main button {
  color: #fff;
  background-color: #00c896;
  border-color: #00c896;
  border-radius: 3px;
}
@font-face {
  font-family: "iconfont"; /* Project id 2647831 */
  src: url("//at.alicdn.com/t/font_2647831_nvqlnxip1yh.woff2?t=1625211539865")
      format("woff2"),
    url("//at.alicdn.com/t/font_2647831_nvqlnxip1yh.woff?t=1625211539865")
      format("woff"),
    url("//at.alicdn.com/t/font_2647831_nvqlnxip1yh.ttf?t=1625211539865")
      format("truetype");
}

.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-dianzan:before {
  content: "\e60c";
}

.icon-icon_comment:before {
  content: "\e602";
}

.icon-zhuanfa:before {
  content: "\e6cf";
}
</style>
